package com.untrance.shop.core.joiner;

import com.untrance.shop.common.vo.CommentVO;
import com.untrance.shop.core.builder.vo.CommentVOBuilder;
import com.untrance.shop.model.Comment;
import com.untrance.shop.model.User;

import java.util.List;

/**
 * @author eugene zadyra
 */
public class CommentJoiner extends AbstractJoiner<Comment, CommentVO> {
    private List<User> users;

    public CommentJoiner(List<User> users) {
        this.users = users;
    }

    @Override
    public CommentVO join(Comment comment) {
        User user = findDependentEntity(users, comment.getUserKey());
        return new CommentVOBuilder(user).createVO(comment);
    }
}
